/*
 * @(#)GSBaseManager.java
 * 
 * Project: BUS
 * 
 * Modify Information:
 * =============================================================================
 * Author Date Description ------------ ----------
 * --------------------------------------------------- Jenny Li 2006-2-10 建立
 * Jenny Li 2006-5-17 添加方法getAllEmergencyOrderType，getEmergencyOrderTypeName，
 * getAllBalanceType，getBalanceDeptTypeName，getAllPayType
 * getPayTypeName，getAllBalanceFlag，getBalanceFlagName
 * getAllCostType，getCostTypeName，getAllPayStatus， getPayStatusName Jenny Li
 * 2006-5-18 添加方法getAllUnPayStatus Copyright Notice:
 * =============================================================================
 * Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room,
 * Science & Technology Building, No. 9 South Street, Zhong Guan Cun, Haidian
 * District, Beijing ,100081, China All rights reserved.
 * 
 * This software is the confidential and proprietary information of Beijing
 * HiTRUST Technology Co., Ltd. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in accordance
 * with the terms of the license agreement you entered into with HiTRUST.
 * 
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.service;

import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import system.base.Warehouse;

import com.hitrust.gs.bean.GSBalanceCategoryBean;
import com.hitrust.gs.bean.GSBalanceParamBean;
import com.hitrust.gs.bean.GSCountryBean;
import com.hitrust.gs.bean.GSDictionaryBean;
import com.hitrust.gs.bean.GSDistrictBean;
import com.hitrust.gs.bean.GSManufactureCategoryBean;
import com.hitrust.gs.bean.GSOrderDetailBean;
import com.hitrust.gs.bean.GSOrganizationBean;
import com.hitrust.gs.bean.GSProviderBean;
import com.hitrust.gs.bean.GSProvinceBean;
import com.hitrust.gs.bean.GSWareHouseBean;
import com.hitrust.gs.dao.GSDictionaryDAO;
import com.hitrust.gs.dao.GSManufactureCategoryDAO;
import com.hitrust.gs.dao.GSOrderDetailDAO;
import com.hitrust.gs.dao.GSOrganizationDAO;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.lib.db.GSBaseDAO;
import com.hitrust.gs.util.date.DateUtil;
import com.hitrust.gs.util.exception.GSException;

import framework.core.DBConnection;

/**
 * @author hitrust
 * 
 */
public class GSBaseManager {
	/**
	 * 取得操作员角色
	 * 
	 * @param aOperId
	 *            操作员编码
	 * @return 操作员角色名称
	 */
	public static String getOperatorRole(String aOperId) {
		String tRs = "";
		if (aOperId.equals("1")) {
			tRs = "录入人员";
		} else if (aOperId.equals("2")) {
			tRs = "初审人员";
		} else if (aOperId.equals("3")) {
			tRs = "复审人员";
		} else if (aOperId.equals("4")) {
			tRs = "提交人员";
		}
		/*
		 * else if(aOperId.equals("11")){ tRs = "录入人员"; }else
		 * if(aOperId.equals("12")){ tRs = "录入人员"; }else
		 * if(aOperId.equals("13")){ tRs = "录入人员"; }else
		 * if(aOperId.equals("14")){ tRs = "录入人员"; }
		 */
		return tRs;
	}

	/**
	 * 取得是否需采购 1=是 0=否
	 * 
	 * @param aId
	 * @return
	 */
	public static String getAllisbuy2(String buy) {
		if (buy.equals("0")) {
			return "否";
		} else {
			return "是";
		}
	}

	/**
	 * 取得有效性编码对应名称
	 * 
	 * @param aId
	 *            有效性编码
	 * @return
	 */
	public static String getValidityName(String aId) {
		String tRs = "无效";
		if (aId.equals("0")) {
			tRs = "有效";
		}
		return tRs;
	}

	/**
	 * 取得有效性编码对应名称 1=有效 0=无效
	 * 
	 * @param aId
	 * @return
	 */
	public static String getValidityName2(String aId) {
		String tRs = "无效";
		if (aId.equals("1")) {
			tRs = "有效";
		}
		return tRs;
	}

	/**
	 * 取得组织名称
	 * 
	 * @param aOrgId
	 *            组织编码
	 * @return
	 */
	public static String getOrgNameByOrgId(String aOrgId) {
		String tRs = "";
		String tSql = "select * from GS_ORGANIZATION where GS_ORG_ID=?";
		Object[] tObj = { aOrgId };
		GSOrganizationBean tGSOrganization = new GSOrganizationBean();
		GSOrganizationDAO tGSOrganiztionDAO = new GSOrganizationDAO();
		try {
			ArrayList tList = tGSOrganiztionDAO.executeQuery(tGSOrganization,
					tSql, tObj);
			if (tList.size() == 1) {
				tGSOrganization = (GSOrganizationBean) tList.get(0);
				tRs = tGSOrganization.getGs_org_name();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 取得二级产品种类的一级编号
	 * 
	 * @param aOrgId
	 *            组织编码
	 * @return
	 */
	public static String getManufactureCategory(String aManufactureId) {
		String tRs = "";
		String tSql = "select * from t_product_CATEGORY where code=?";
		Object[] tObj = { aManufactureId };
		GSManufactureCategoryBean tGSManufactureCategoryBean = new GSManufactureCategoryBean();
		GSManufactureCategoryDAO ttGSManufactureCategoryDAO = new GSManufactureCategoryDAO();
		try {
			ArrayList tList = ttGSManufactureCategoryDAO.executeQuery(
					tGSManufactureCategoryBean, tSql, tObj);
			if (tList.size() == 1) {
				tGSManufactureCategoryBean = (GSManufactureCategoryBean) tList
						.get(0);
				tRs = tGSManufactureCategoryBean
						.getGs_manufacture_category_id1();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 查询所有国家信息
	 * 
	 * @return
	 */
	public static ArrayList getAllCountry() {
		ArrayList tRs = new ArrayList();

		String tSql = "select * from GS_COUNTRY ";
		Object[] tObj = {};
		try {
			GSBaseDAO tBaseDAO = new GSBaseDAO();
			tRs = tBaseDAO.executeQuery(new GSCountryBean(), tSql, tObj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 查询所有省份信息
	 * 
	 * @return
	 */
	public static ArrayList getAllProvince() {
		ArrayList tRs = new ArrayList();

		String tSql = "select * from GS_PROVINCE ";
		Object[] tObj = {};
		try {
			GSBaseDAO tBaseDAO = new GSBaseDAO();
			tRs = tBaseDAO.executeQuery(new GSProvinceBean(), tSql, tObj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 由省代码查询其所有的城市
	 * 
	 * @param aProvCode
	 *            省代码
	 * @return
	 */
	public static ArrayList getAllDistinctByProv(String aProvCode) {
		ArrayList tRs = new ArrayList();

		String tSql = "select * from GS_DISTRICT where GS_PROVINCE_CODE=? ";
		Object[] tObj = {};
		try {
			GSBaseDAO tBaseDAO = new GSBaseDAO();
			tRs = tBaseDAO.executeQuery(new GSDistrictBean(), tSql, tObj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 查询所有城市
	 * 
	 * @return
	 */
	public static ArrayList getAllDistinct() {
		ArrayList tRs = new ArrayList();

		String tSql = "select * from GS_DISTRICT";
		Object[] tObj = {};
		try {
			GSBaseDAO tBaseDAO = new GSBaseDAO();
			tRs = tBaseDAO.executeQuery(new GSDistrictBean(), tSql, tObj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 查询所有供应商
	 * 
	 * @return
	 */
	public static ArrayList getAllProvider() {
		ArrayList tRs = new ArrayList();

		String tSql = "select * from t_PROVIDER";
		Object[] tObj = {};
		try {
			GSBaseDAO tBaseDAO = new GSBaseDAO();
			tRs = tBaseDAO.executeQuery(new GSProviderBean(), tSql, tObj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 查询所有结算分类
	 * 
	 * @return
	 */
	public static ArrayList getAllBalanceCategory() {
		ArrayList tRs = new ArrayList();

		String tSql = "select * from GS_balance_category where GS_DIRTY=1";
		Object[] tObj = {};
		try {
			GSBaseDAO tBaseDAO = new GSBaseDAO();
			tRs = tBaseDAO
					.executeQuery(new GSBalanceCategoryBean(), tSql, tObj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 查询公司属性
	 * 
	 * @return
	 */
	public static String[][] getAllCorpProperty() {
		String[][] tProperty = new String[8][2];
		tProperty[0][0] = "1";
		tProperty[0][1] = "国营";
		tProperty[1][0] = "2";
		tProperty[1][1] = "私营";
		tProperty[2][0] = "3";
		tProperty[2][1] = "股份制";
		tProperty[3][0] = "4";
		tProperty[3][1] = "合资";
		tProperty[4][0] = "5";
		tProperty[4][1] = "外资";
		tProperty[5][0] = "6";
		tProperty[5][1] = "有限责任公司";
		tProperty[6][0] = "7";
		tProperty[6][1] = "集体企业";
		tProperty[7][0] = "8";
		tProperty[7][1] = "独资";
		return tProperty;
	}

	/**
	 * 取得公司属性代码对应的公司属性名称
	 * 
	 * @param aPropertyCode
	 *            属性代码
	 * @return
	 */
	public static String getCorpPropertyName(String aPropertyCode) {
		String tStr = "";
		String[][] tProperties = GSBaseManager.getAllCorpProperty();
		for (int i = 0; i < tProperties.length; i++) {
			String[] tStrs = tProperties[i];
			if (tStrs[0].equals(aPropertyCode)) {
				tStr = tStrs[1];
				break;
			}
		}
		return tStr;
	}

	/**
	 * 取得国家名称
	 * 
	 * @param aCountryCode
	 *            国家代码
	 * @return
	 */
	public static String getCountryName(String aCountryCode) {
		String tRs = "";
		String tSql = "select * from GS_COUNTRY where GS_EN_COUNTRY_NAME=?";
		Object tObj[] = { aCountryCode };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(new GSCountryBean(),
					tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSCountryBean) tList.get(0)).getGs_country_name();
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		return tRs;
	}

	public static Map getCountryName() {
		Map countryMap = new HashMap();
		String tSql = "select * from GS_COUNTRY";

		try {
			ArrayList tList = new GSBaseDAO().executeQuery(new GSCountryBean(),
					tSql, null);
			for (int i = 0; i < tList.size(); i++) {
				GSCountryBean country = ((GSCountryBean) tList.get(i));
				countryMap.put(country.getGs_country_code(),
						country.getGs_country_name());
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		return countryMap;
	}

	/**
	 * 取得省名称
	 * 
	 * @param aProvinceCode
	 *            省代码
	 * @return
	 */
	public static String getProvinceName(String aProvinceCode) {
		String tRs = "";
		String tSql = "select * from GS_PROVINCE where GS_PROVINCE_CODE=?";
		Object tObj[] = { aProvinceCode };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSProvinceBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSProvinceBean) tList.get(0)).getGs_province_name();
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 取得城市名称
	 * 
	 * @param aDistrictCode
	 *            城市代码
	 * @return
	 */
	public static String getDistrictName(String aDistrictCode) {
		String tRs = "";
		String tSql = "select * from GS_DISTRICT where GS_DISTRICT_CODE=?";
		Object tObj[] = { aDistrictCode };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSDistrictBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSDistrictBean) tList.get(0)).getGs_district_name();
			} else {
				GSLogWriter.debug("----查不到地区信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得供应商名称
	 * 
	 * @param aProviderId
	 *            供应商编码
	 * @return
	 */
	public static String getProviderName(String aProviderId) {
		String tRs = "";
		String tSql = "select * from t_PROVIDER where code=?";
		Object tObj[] = { aProviderId };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSProviderBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSProviderBean) tList.get(0)).getGs_provider_name();
			} else {
				GSLogWriter.debug("----查不到供应商信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得供应商名称
	 * 
	 * @param aProviderId
	 *            供应商编码
	 * @return
	 */
	public static String getProviderShortName(String aProviderId) {
		String tRs = "";
		String tSql = "select * from T_PROVIDER where CODE=?";
		Object tObj[] = { aProviderId };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSProviderBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSProviderBean) tList.get(0))
						.getGs_provider_shortname();
			} else {
				GSLogWriter.debug("----查不到供应商信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得供应商名称
	 * 
	 * @param aProviderId
	 *            供应商编码
	 * @return
	 */
	public static String getProviderTradeflat(String aProviderId) {
		String tRs = "";
		String tSql = "select * from T_PROVIDER where CODE=?";
		Object tObj[] = { aProviderId };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSProviderBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSProviderBean) tList.get(0))
						.getGs_is_tradeflat_provider();
			} else {
				GSLogWriter.debug("----查不到供应商信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得仓库名称 根据code
	 * **/
	public static String getWareHoseNameByCode(String code) {
		String name = "";
		String sql = "select * from t_warehouse where code = '" + code + "'";
		Object[] tobj = {};

		try {
			ArrayList wareHouseList = new GSBaseDAO().executeQuery(
					new GSWareHouseBean(), sql, tobj);
			if (wareHouseList.size() > 0) {
				name = ((GSWareHouseBean) wareHouseList.get(0)).getName();
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
		}
		return name;
	}

	/**
	 * 取得产品类别名称
	 * 
	 * @param aCategoryId
	 *            产品种类编码
	 * @return
	 */
	public static String getManufactureCategoryName(String aCategoryId) {
		String tRs = "";
		String tSql = "select * from T_PRODUCT_CATEGORY where CODE=?";
		Object tObj[] = { aCategoryId };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSManufactureCategoryBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSManufactureCategoryBean) tList.get(0))
						.getGs_manufacture_category_name();
			} else {
				GSLogWriter.debug("----查不到产品种类信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得结算分类名称
	 * 
	 * @param aCategoryId
	 *            产品种类编码
	 * @return
	 */
	public static String getBalanceCategoryName(String aBalanceCategoryNo) {
		String tRs = "";
		String tSql = "select * from GS_BALANCE_CATEGORY where GS_balance_CATEGORY_NO=?";
		Object tObj[] = { aBalanceCategoryNo };
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSBalanceCategoryBean(), tSql, tObj);
			if (tList.size() > 0) {
				tRs = ((GSBalanceCategoryBean) tList.get(0))
						.getGs_balance_category_name();
			} else {
				GSLogWriter.debug("----查不到结算分类信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得所有订单种类
	 * 
	 * @return
	 */
	public static String[][] getAllOrderCategory() {
		ArrayList tList = new ArrayList();
		String[][] tStr = new String[3][2];
		tStr[0][0] = "0";
		tStr[0][1] = "正常采购";
		tStr[1][0] = "1";
		tStr[1][1] = "应急采购";
		tStr[2][0] = "2";
		tStr[2][1] = "补单";
		return tStr;
	}

	/**
	 * 用于新增订单
	 * 
	 * @return
	 */
	public static String[][] getAllOrderCategory2() {
		ArrayList tList = new ArrayList();
		String[][] tStr = new String[2][2];
		tStr[0][0] = "0";
		tStr[0][1] = "正常采购";
		tStr[1][0] = "1";
		tStr[1][1] = "应急采购";
		return tStr;
	}

	/**
	 * 根据订货单位取得单位名称
	 * 
	 * @param aOrderDeptId
	 *            订货单位编码
	 * @return
	 */
	public static String getOrderDeptName(String aOrderDeptId) throws Exception {
		String tRs = "";
		DBConnection con = null;
		try {
			con = DBConnection.open(true);
			Warehouse ware = Warehouse.fetchByCode(con, aOrderDeptId);
			if (ware != null) {
				tRs = ware.getName();
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		} finally {
			if (con != null) {
				con.close();
			}
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 根据订单种类取得订单种类名称
	 * 
	 * @param aOrderCategory
	 *            订单种类
	 * @return
	 */
	public static String getOrderCategoryName(String aOrderCategory) {
		String tRs = "";
		String[][] tStrs = getAllOrderCategory();
		for (int i = 0; i < tStrs.length; i++) {
			if (aOrderCategory.equals(tStrs[i][0])) {
				tRs = tStrs[i][1];
			}
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 根据订单状态码查询订单状态名称
	 * 
	 * @param aOrderStatus
	 *            订货状态编码
	 * @return
	 */
	public static String getOrderStatusName(String aOrderStatus) {
		String tRs = "";
		String[][] tStrs = getAllOrderStatus();
		for (int i = 0; i < tStrs.length; i++) {
			if (aOrderStatus.equals(tStrs[i][0])) {
				tRs = tStrs[i][1];
				break;
			}
		}
		GSLogWriter.debug("name=" + tRs);
		return tRs;
	}

	/**
	 * 取得所有订单状态
	 * 
	 * @return
	 */
	public static String[][] getAllOrderStatus() {
		String[][] tStr = new String[19][2];
		tStr[0][0] = "1";
		tStr[0][1] = "申请";
		tStr[1][0] = "2";
		tStr[1][1] = "初审通过";
		tStr[2][0] = "3";
		tStr[2][1] = "复审通过";
		tStr[3][0] = "4";
		tStr[3][1] = "初审未通过";
		tStr[4][0] = "5";
		tStr[4][1] = "复审未通过";
		tStr[5][0] = "6";
		tStr[5][1] = "提交";
		tStr[6][0] = "7";
		tStr[6][1] = "核准";
		tStr[7][0] = "8";
		tStr[7][1] = "未核准";
		tStr[8][0] = "9";
		tStr[8][1] = "订货中";
		tStr[9][0] = "10";
		tStr[9][1] = "订单确认";
		tStr[10][0] = "11";
		tStr[10][1] = "订单拒绝";
		tStr[11][0] = "12";
		tStr[11][1] = "交货确认";
		tStr[12][0] = "13";
		tStr[12][1] = "收款确认";
		tStr[13][0] = "14";
		tStr[13][1] = "完成";
		tStr[14][0] = "18";
		tStr[14][1] = "补单";
		tStr[15][0] = "19";
		tStr[15][1] = "补单确认";
		tStr[16][0] = "20";
		tStr[16][1] = "退货";
		tStr[17][0] = "21";
		tStr[17][1] = "取消";
		tStr[18][0] = "22";
		tStr[18][1] = "作废";
		/*
		 * tStr[20][0] = "1"; tStr[20][1] = "1"; tStr[21][0] = "1"; tStr[21][1]
		 * = "1"; tStr[22][0] = "1"; tStr[22][1] = "1";
		 */
		// tStr[23][0] = "1";
		// tStr[23][1] = "1";
		return tStr;
	}

	/**
	 * 根据送货时间类型取得时间段
	 * 
	 * @param aTime
	 *            送货时间
	 * @return
	 */
	public static String getDeliverGoodsTime(String aTime) {
		String tRs = "";
		if (aTime.equals("1")) {
			tRs = "8:00-12:00";
		} else if (aTime.equals("2")) {
			tRs = "13:00-18:00";
		} else if (aTime.equals("3")) {
			tRs = "全天";
		}
		return tRs;
	}

	/**
	 * 取得所有类型订货时间
	 * 
	 * @return
	 */
	public static String[][] getDeliverGoodsTimeType() {
		String[][] tRs = new String[3][2];
		tRs[0][0] = "1";
		tRs[0][1] = "8:00-12:00";
		tRs[1][0] = "2";
		tRs[1][1] = "13:00-18:00";
		tRs[2][0] = "3";
		tRs[2][1] = "全天";
		return tRs;
	}

	/**
	 * 取得所有交易内容
	 * 
	 * @return
	 */
	public static String[][] getTradeflat() {
		String[][] tRs = new String[3][2];
		tRs[0][0] = "0";
		tRs[0][1] = "网上特约产品";
		tRs[1][0] = "1";
		tRs[1][1] = "网上产品";
		tRs[2][0] = "2";
		tRs[2][1] = "非网上产品";
		return tRs;
	}

	/**
	 * 取得产品类型
	 * 
	 * @return
	 */
	public static String[][] getProductType() {
		String[][] tRs = new String[3][2];
		tRs[0][0] = "1";
		tRs[0][1] = "正式产品";
		tRs[1][0] = "0";
		tRs[1][1] = "临时产品";
		tRs[2][0] = "2";
		tRs[2][1] = "14位临时产品";
		return tRs;
	}

	/**
	 * 取得产品类型
	 * 
	 * @return
	 */
	public static String getProductTypeByCode(String isNomer) {
		String tRs = "";
		if (isNomer.equals("1")) {
			tRs = "正式产品";
		} else if (isNomer.equals("0")) {
			tRs = "临时产品";
		}
		return tRs;
	}

	/**
	 * 取得交易平台的名称
	 * 
	 * @param aTime
	 *            交易ID
	 * @return
	 */
	public static String getTradeflatName(String aId) {
		String tRs = "";
		if (aId.equals("1")) {
			tRs = "网上产品";
		} else if (aId.equals("2")) {
			tRs = "非网上产品";
		} else if (aId.equals("0")) {
			tRs = "网上特约产品";
		}
		return tRs;
	}

	/**
	 * 取得配送模式名称
	 * 
	 * @param aDeliverMode
	 *            配送模式编码
	 * @return
	 */
	public static String getDeliverModeName(String aDeliverMode) {
		return getDictioanryName(aDeliverMode);
	}

	/**
	 * 取得结算模式名称
	 * 
	 * @param aDeliverMode
	 *            结算模式编码
	 * @return
	 */
	public static String getBalanceModeName(String aDeliverMode) {
		/*
		 * String tRs = ""; if (aDeliverMode.equals("1")) { tRs = "定期结算"; } else
		 * if (aDeliverMode.equals("3")) { tRs = "其他"; } else { tRs =
		 * aDeliverMode.trim(); } return tRs;
		 */
		return getDictioanryName(aDeliverMode);
	}

	/**
	 * 取得订单明细中订单备注
	 * 
	 * @param aOrderDetailId
	 * @return
	 */
	public static String getOrderDetailNote(String aOrderDetailId) {
		String tRs = "";
		GSOrderDetailDAO tOrderDetailDAO = new GSOrderDetailDAO();
		try {
			GSOrderDetailBean tOrderDetailBean = tOrderDetailDAO
					.queryOrderDetailByDetailId(aOrderDetailId);
			tRs = tOrderDetailBean.getGs_order_detail_note();
		} catch (Exception e) {
			GSLogWriter.error(new GSBaseManager(), e.toString());
		}
		return tRs;
	}

	/**
	 * 取得所有订单明细状态 申购信息综合查询中用到
	 * 
	 * @return
	 */
	public static String[][] getAllOrderDetailStatusForOrder() {
		String[][] tStr = new String[6][2];
		tStr[0][0] = "3";
		tStr[0][1] = "复审通过";
		tStr[1][0] = "9";
		tStr[1][1] = "订货中";
		tStr[2][0] = "10";
		tStr[2][1] = "已确认";
		tStr[3][0] = "11";
		tStr[3][1] = "已拒绝";
		tStr[4][0] = "12";
		tStr[4][1] = "交货确认";
		tStr[5][0] = "22";
		tStr[5][1] = "已作废";
		return tStr;
	}

	/**
	 * 取得所有订单明细状态
	 * 
	 * @return
	 */
	public static String[][] getAllOrderDetailStatus() {
		String[][] tStr = new String[15][2];
		tStr[0][0] = "1";
		tStr[0][1] = "已申请";
		tStr[1][0] = "2";
		tStr[1][1] = "初审通过";
		tStr[2][0] = "3";
		tStr[2][1] = "复审通过";
		tStr[3][0] = "4";
		tStr[3][1] = "初审未通过";
		tStr[4][0] = "5";
		tStr[4][1] = "复审未通过";
		tStr[5][0] = "6";
		tStr[5][1] = "已提交";
		tStr[6][0] = "7";
		tStr[6][1] = "已核准";
		tStr[7][0] = "8";
		tStr[7][1] = "未核准";
		tStr[8][0] = "9";
		tStr[8][1] = "订货中";
		tStr[9][0] = "10";
		tStr[9][1] = "已确认";
		tStr[10][0] = "11";
		tStr[10][1] = "已拒绝";
		tStr[11][0] = "12";
		tStr[11][1] = "交货确认";
		// tStr[12][0] = "13";
		// tStr[12][1] = "收款确认";
		tStr[12][0] = "14";
		tStr[12][1] = "已完成";
		// tStr[14][0] = "18";
		// tStr[14][1] = "补单";
		// tStr[15][0] = "19";
		// tStr[15][1] = "补单确认";
		// tStr[16][0] = "20";
		// tStr[16][1] = "已退货";
		tStr[13][0] = "21";
		tStr[13][1] = "已取消";
		tStr[14][0] = "22";
		tStr[14][1] = "已作废";
		return tStr;
	}

	/**
	 * 取得订单提交后的所有状态
	 * 
	 * @return
	 */
	public static String[][] getAllOrderDetailStatusAfterCommit() {
		String[][] tStr = new String[7][2];
		tStr[0][0] = "6";
		tStr[0][1] = "已提交";
		tStr[1][0] = "7";
		tStr[1][1] = "已核准";
		tStr[2][0] = "8";
		tStr[2][1] = "未核准";
		tStr[3][0] = "9";
		tStr[3][1] = "订货中";
		tStr[4][0] = "10";
		tStr[4][1] = "已确认";
		tStr[5][0] = "11";
		tStr[5][1] = "已拒绝";
		tStr[6][0] = "22";
		tStr[6][1] = "已作废";
		return tStr;
	}

	/**
	 * 取得可作取消的订单状态
	 * 
	 * @return
	 */
	public static String[][] getAllOrderDetailStatusForCancle() {
		String[][] tStr = new String[8][2];
		tStr[0][0] = "1";
		tStr[0][1] = "已申请";
		tStr[1][0] = "2";
		tStr[1][1] = "初审通过";
		tStr[2][0] = "3";
		tStr[2][1] = "复审通过";
		tStr[3][0] = "4";
		tStr[3][1] = "初审未通过";
		tStr[4][0] = "5";
		tStr[4][1] = "复审未通过";
		tStr[5][0] = "6";
		tStr[5][1] = "已提交";
		tStr[6][0] = "8";
		tStr[6][1] = "未核准";
		tStr[7][0] = "11";
		tStr[7][1] = "已拒绝";
		return tStr;

	}

	/**
	 * 取得可作取消的巴士物资订单状态
	 * 
	 * @return
	 */
	public static String[][] getAllBusOrderDetailStatusForCancle() {
		String[][] tStr = new String[3][2];
		tStr[0][0] = "7";
		tStr[0][1] = "已核准";
		tStr[1][0] = "9";
		tStr[1][1] = "订货中";
		// tStr[2][0] = "10";
		// tStr[2][1] = "已确认";
		tStr[2][0] = "11";
		tStr[2][1] = "已拒绝";
		// tStr[4][0] = "50";
		// tStr[4][1] = "申请取消";

		return tStr;

	}

	/**
	 * 取得所有巴士物资可提交的订单状态
	 * 
	 * @return
	 */
	public static String[][] getAllBusOrderDetailStatusForSubmit() {
		String[][] tStr = new String[3][2];
		tStr[0][0] = "7";
		tStr[0][1] = "已核准";
		tStr[1][0] = "9";
		tStr[1][1] = "订货中";
		tStr[2][0] = "10";
		tStr[2][1] = "已确认";
		return tStr;

	}

	public static String[][] getAllBusOrderDetailStatusForSubmit2() {
		String[][] tStr = new String[5][2];
		tStr[0][0] = "3";
		tStr[0][1] = "复审通过";
		tStr[1][0] = "6";
		tStr[1][1] = "已提交";
		tStr[2][0] = "7";
		tStr[2][1] = "已核准";
		tStr[3][0] = "9";
		tStr[3][1] = "订货中";
		tStr[4][0] = "10";
		tStr[4][1] = "已确认";
		return tStr;

	}

	/**
	 * 取得巴士物资可修改的订单状态
	 * 
	 * @return
	 */
	public static String[][] getAllBusOrderDetailStatusForModify() {
		String[][] tStr = new String[2][2];

		tStr[0][0] = "7";
		tStr[0][1] = "已核准";

		tStr[1][0] = "9";
		tStr[1][1] = "订货中";

		return tStr;

	}

	/**
	 * 取得巴士物资可修改的订单状态
	 * 
	 * @return
	 */
	/*
	 * public static String[][] getManagerOrderStatusForModify() { String[][]
	 * tStr = new String[22][2]; tStr[0][0] = "1"; tStr[0][1] = "已申请";
	 * tStr[1][0] = "2"; tStr[1][1] = "初审通过"; tStr[2][0] = "3"; tStr[2][1] =
	 * "复审通过"; tStr[3][0] = "4"; tStr[3][1] = "初审未通过"; tStr[4][0] = "5";
	 * tStr[4][1] = "复审未通过"; tStr[5][0] = "6"; tStr[5][1] = "已提交"; tStr[6][0] =
	 * "7"; tStr[6][1] = "已核准"; tStr[7][0] = "8"; tStr[7][1] = "未核准"; tStr[8][0]
	 * = "9"; tStr[8][1] = "订货中"; tStr[9][0] = "10"; tStr[9][1] = "已确认";
	 * tStr[10][0] = "11"; tStr[10][1] = "已拒绝"; tStr[11][0] = "12"; tStr[11][1]
	 * = "交货确认"; tStr[12][0] = "13"; tStr[12][1] = "收款确认"; tStr[13][0] = "14";
	 * tStr[13][1] = "已完成";
	 * 
	 * tStr[14][0] = "18"; tStr[14][1] = "已补单"; tStr[15][0] = "19"; tStr[15][1]
	 * = "补单确认"; tStr[16][0] = "20"; tStr[16][1] = "已退货"; tStr[17][0] = "21";
	 * tStr[17][1] = "已取消"; tStr[18][0] = "22"; tStr[18][1] = "已作废";
	 * 
	 * tStr[19][0] = "50"; tStr[19][1] = "申请取消"; tStr[20][0] = "51"; tStr[20][1]
	 * = "退货申请"; tStr[21][0] = "52"; tStr[21][1] = "退货拒绝"; return tStr;
	 * 
	 * }
	 */

	/**
	 * 取得订单明细状态中文说明
	 * 
	 * @param aOrderDetailStatus
	 *            订单明细状态编码
	 * @return
	 */
	public static String getOrderDetailStatusName(String aOrderDetailStatus) {
		String tRs = "";
		String[][] tStr = getAllOrderDetailStatus();
		for (int i = 0; i < tStr.length; i++) {
			if (aOrderDetailStatus.equals(tStr[i][0])) {
				tRs = tStr[i][1];
				break;
			}
		}
		return tRs;
	}

	/**
	 * 取得是否是交易平台产品的中文描述
	 * 
	 * @param aIsTradeManuf
	 *            是否交易平台产品编码
	 * @return
	 */
	public static String getIsTradeManuf(String aIsTradeManuf) {
		String tRs = "";
		if (aIsTradeManuf.equals("0")) {
			tRs = "网上特约产品";
		} else if (aIsTradeManuf.equals("1")) {
			tRs = "网上产品";
		} else if (aIsTradeManuf.equals("2")) {
			tRs = "非网上产品";
		}
		return tRs;
	}

	/**
	 * 获取性别名称
	 * 
	 * @param aSexCode
	 * @return
	 */
	public static String getSexName(String aSexCode) {
		String tRs = "";
		if (aSexCode.equals("0")) {
			tRs = "男";
		} else if (aSexCode.equals("1")) {
			tRs = "女";
		}
		return tRs;
	}

	/**
	 * 获取采购类型名称
	 * 
	 * @param aCategoryId
	 * @return
	 */
	public static String getOrderCategoryTag(String aCategoryId) {
		String tRs = "";
		if (aCategoryId.equals("1")) {
			tRs = "出货单";
		} else if (aCategoryId.equals("2")) {
			tRs = "补单";
		}
		return tRs;
	}

	/**
	 * 获取所有采购类型名称
	 * 
	 * @return
	 */
	public static String[][] getAllOrderCategoryTag() {
		String[][] tStr = new String[2][2];
		tStr[0][0] = "1";
		tStr[0][1] = "出货单";
		tStr[1][0] = "2";
		tStr[1][1] = "补单";
		return tStr;

	}

	/**
	 * 获取明细状态名称
	 * 
	 * @param aSexCode
	 * @return
	 */
	public static String getOrderDetailStatus(String aStatusId) {
		String tRs = "";
		if (aStatusId.equals("1")) {
			tRs = "未确认";
		} else if (aStatusId.equals("2")) {
			tRs = "直接确认";
		} else if (aStatusId.equals("3")) {
			tRs = "调整确认";
		}
		return tRs;
	}

	/**
	 * 获取所有应急采购明细状态名称
	 * 
	 * @return
	 */
	public static String[][] getOrderDetailStatusTag() {
		String[][] tStr = new String[3][2];
		tStr[0][0] = "1";
		tStr[0][1] = "未确认";
		tStr[1][0] = "2";
		tStr[1][1] = "直接确认";
		tStr[2][0] = "3";
		tStr[2][1] = "调整确认";

		return tStr;

	}

	/**
	 * 获取合同类型名称
	 * 
	 * @param aTypeId
	 * @return
	 */
	public static String getBargain(String aTypeId) {
		String tRs = "";
		if (aTypeId.equals("1")) {
			tRs = "主合同";
		} else if (aTypeId.equals("2")) {
			tRs = "副合同";
		}
		return tRs;
	}

	/**
	 * 获取客户类型名称
	 * 
	 * @param aCategoryId
	 * @return
	 */
	public static String getUserType(String aTypeId) {
		String tRs = "";
		if (aTypeId.equals("2")) {
			tRs = "供应商";
		} else if (aTypeId.equals("1")) {
			tRs = "采购用户";
		}
		return tRs;
	}

	/**
	 * 获取合同信息有效性
	 * 
	 * @param aCategoryId
	 * @return
	 */
	public static String getEffect(String aId) {
		String tRs = "";
		if (aId.equals("1")) {
			tRs = "有效";
		} else if (aId.equals("2")) {
			tRs = "无效";
		}
		return tRs;
	}

	/**
	 * 获取合同信息有效性名称
	 * 
	 * @return
	 */
	public static String[][] getAllEffect() {
		String[][] tStr = new String[2][2];
		tStr[0][0] = "1";
		tStr[0][1] = "有效";
		tStr[1][0] = "2";
		tStr[1][1] = "无效";
		return tStr;

	}

	/**
	 * 取得分页参数
	 * 
	 * @param tForm
	 *            基类form
	 * @return
	 * @throws GSException
	 */
	public static String[] getPageNoAndPageSize(GSBaseForm tForm)
			throws GSException {
		String choice = tForm.getChoice();
		if (choice == null)
			choice = tForm.getRequest().getParameter("choice");
		int totalRecords = 0;
		int pageSize;
		int pageNo;
		String[] tRs = new String[3];
		if (choice.trim().equalsIgnoreCase("current")) {// 非第一次，点击go
			// 从参数中取得所有行数
			totalRecords = tForm.getTotalRecords();
			// 从参数中取得页大小
			pageSize = tForm.getPageSize();
			// 从参数中取得PageNo
			pageNo = tForm.getPageNo();
		} else {// 点击的是first/prev/next/last
				// 从参数中取得所有行数
			totalRecords = tForm.getTotalRecords();
			// 从参数中取得页大小
			pageSize = tForm.getPageSize();
			// 从参数中取得PageNo
			pageNo = tForm.getPageNo();
			if (totalRecords == 0 && pageSize == 0 && pageNo == 0) {
				totalRecords = Integer.parseInt(tForm.getRequest()
						.getParameter("totalRecords"));
				pageSize = Integer.parseInt(tForm.getRequest().getParameter(
						"pageSize"));
				pageNo = Integer.parseInt(tForm.getRequest().getParameter(
						"pageNo"));
			}
			// 根据点击的按钮重新计算PageNo
			if (choice.equals("next")) {
				pageNo++;
			}
			if (choice.equals("prev")) {
				pageNo--;
			}
			if (choice.equals("first")) {
				pageNo = 1;
			}
			if (choice.equals("last")) {
				pageNo = (totalRecords % pageSize == 0) ? totalRecords
						/ pageSize : totalRecords / pageSize + 1;
			}
		}
		int n = (totalRecords % pageSize == 0) ? totalRecords / pageSize
				: totalRecords / pageSize + 1;
		if (pageNo > n) {
			pageNo = n;
		}
		tRs[0] = String.valueOf(pageNo);
		tRs[1] = String.valueOf(pageSize);
		tRs[2] = String.valueOf(totalRecords);
		return tRs;
	}

	/**
	 * 取得所有应急采购类型
	 * 
	 * @return
	 */
	public static String[][] getAllEmergencyOrderType() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "1";
		tRs[0][1] = "出货单";
		tRs[1][0] = "2";
		tRs[1][1] = "补单";
		return tRs;
	}

	/**
	 * 取得应急采购类型名称
	 * 
	 * @param aType
	 * @return
	 */
	public static String getEmergencyOrderTypeName(String aType) {
		String[][] tRs = getAllEmergencyOrderType();
		String tStr = "";
		for (int i = 0; i < tRs.length; i++) {
			String[] temp = tRs[i];
			if (temp[0].equals(aType)) {
				tStr = temp[1];
				break;
			}
		}
		return tStr;
	}

	/**
	 * 取得所有结算单位类型
	 * 
	 * @return
	 */
	public static String[][] getAllBalanceType() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "1";
		tRs[0][1] = "订货单位";
		tRs[1][0] = "2";
		tRs[1][1] = "供应商";
		return tRs;
	}

	/**
	 * 取得结算单位类型名称
	 * 
	 * @param aBalDeptId
	 * @return
	 */
	public static String getBalanceDeptTypeName(String aBalDeptId) {
		String tName = "";
		String[][] tRs = getAllBalanceType();
		for (int i = 0; i < tRs.length; i++) {
			String[] temp = tRs[i];
			if (temp[0].equals(aBalDeptId)) {
				tName = temp[1];
				break;
			}
		}
		return tName;

	}

	/**
	 * 取得所有收付类型
	 * 
	 * @return
	 */
	public static String[][] getAllPayType() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "1";
		tRs[0][1] = "收款";
		tRs[1][0] = "2";
		tRs[1][1] = "付款";
		return tRs;
	}

	/**
	 * 取得收付类型名称
	 * 
	 * @param aPayTypeId
	 * @return
	 */
	public static String getPayTypeName(String aPayTypeId) {
		String tName = "";
		String[][] tRs = getAllPayType();
		for (int i = 0; i < tRs.length; i++) {
			String[] temp = tRs[i];
			if (temp[0].equals(aPayTypeId)) {
				tName = temp[1];
				break;
			}
		}
		return tName;

	}

	/**
	 * 取得所有结算标志
	 * 
	 * @return
	 */
	public static String[][] getAllBalanceFlag() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "0";
		tRs[0][1] = "未结算";
		tRs[1][0] = "1";
		tRs[1][1] = "已结算";
		return tRs;
	}

	/**
	 * 取得结算标志名称
	 * 
	 * @param aBalanceId
	 * @return
	 */
	public static String getBalanceFlagName(String aBalanceId) {
		String tName = "";
		String[][] tRs = getAllBalanceFlag();
		for (int i = 0; i < tRs.length; i++) {
			String[] temp = tRs[i];
			if (temp[0].equals(aBalanceId)) {
				tName = temp[1];
				break;
			}
		}
		return tName;
	}

	/**
	 * 取得所有费用类型
	 * 
	 * @return
	 */
	public static String[][] getAllCostType() {
		String[][] tStr = new String[6][2];
		tStr[0][0] = "0";
		tStr[0][1] = "零配件结算款（新车配套）";
		tStr[1][0] = "1";
		tStr[1][1] = "零配件结算款（维修类）";
		tStr[2][0] = "2";
		tStr[2][1] = "油品类结算款";
		tStr[3][0] = "3";
		tStr[3][1] = "整车结算款";
		tStr[4][0] = "4";
		tStr[4][1] = "返利";
		tStr[5][0] = "5";
		tStr[5][1] = "差价";
		return tStr;
	}

	/**
	 * 取得费用类型名称
	 * 
	 * @param aCostTypeId
	 *            费用类型序号
	 * @return //
	 */
	public static String getCostTypeName(String aCostTypeId) {
		String tName = "";
		String[][] tRs = getAllCostType();
		for (int i = 0; i < tRs.length; i++) {
			String[] temp = tRs[i];
			if (temp[0].equals(aCostTypeId)) {
				tName = temp[1];
				break;
			}
		}
		return tName;

	}

	/**
	 * 取得所有应收应付状态
	 * 
	 * @return
	 */
	public static String[][] getAllPayStatus() {
		String[][] tRs = new String[3][2];
		tRs[0][0] = "1";
		tRs[0][1] = "未完成";
		tRs[1][0] = "2";
		tRs[1][1] = "部分完成";
		tRs[2][0] = "3";
		tRs[2][1] = "全部完成";
		return tRs;
	}

	/**
	 * 根据状态编号取得状态名称
	 * 
	 * @param aStatus
	 *            状态编码
	 * @return
	 */
	public static String getPayStatusName(String aStatus) {
		String tName = "";
		String[][] tRs = getAllPayStatus();
		for (int i = 0; i < tRs.length; i++) {
			if (tRs[i][0].equals(aStatus)) {
				tName = tRs[i][1];
				break;
			}
		}
		return tName;
	}

	/**
	 * 查询所有未完成结算状态
	 * 
	 * @return
	 */
	public static String[][] getAllUnPayStatus() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "1";
		tRs[0][1] = "未完成";
		tRs[1][0] = "2";
		tRs[1][1] = "部分完成";
		return tRs;
	}

	/**
	 * 根据页面上选中的月份和预设的报表起止日期得到最终的报表时间段 专用于报表
	 * 
	 * @param year
	 * @param month
	 * @return
	 */
	public static String[] getPreSetDate(int year, int month) {
		String tRs = "";
		String[] rs = new String[2];

		String tSql = "select * from GS_BALANCE_PARAM ";
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSBalanceParamBean(), tSql, null);
			if (tList.size() > 0) {
				tRs = ((GSBalanceParamBean) tList.get(0))
						.getGs_balance_date_type();
				Calendar c = Calendar.getInstance();

				if (GSBaseConstants.NATURE_BALANCE_DATE.equals(tRs)) {
					c.set(year, month - 1, 1);
					int day = c.getActualMaximum(Calendar.DAY_OF_MONTH);
					rs[0] = "" + year + "-"
							+ (month > 9 ? "" + (month) : "0" + (month))
							+ "-01";
					rs[1] = "" + year + "-"
							+ (month > 9 ? "" + (month) : "0" + (month)) + "-"
							+ day;
				} else {
					GSBalanceParamBean b = (GSBalanceParamBean) tList.get(0);
					String startDate = Integer.parseInt(b
							.getGs_balance_start_date()) <= 9 ? "0"
							+ b.getGs_balance_start_date() : b
							.getGs_balance_start_date();
					String endDate = Integer.parseInt(b
							.getGs_balance_end_date()) <= 9 ? "0"
							+ b.getGs_balance_end_date() : b
							.getGs_balance_end_date();

					int tStrDay = Integer.parseInt(startDate);
					int tEndDay = Integer.parseInt(endDate);
					String tCurDay = DateUtil.getCurrentDate("yyyyMMdd");
					int curYear = year;
					int curMonth = month;
					if (tStrDay > tEndDay || tStrDay == tEndDay) { // 开始日期大于等于结束日期
						if (tCurDay.substring(4, 6).equals("01")) { // 如果当前月份为1月,则开始区间的年为上一年份
							rs[0] = DateUtil.getSpecDate(curYear - 1, 12,
									tStrDay, "yyyy-MM-dd");
							rs[1] = DateUtil.getSpecDate(curYear, 1, tEndDay,
									"yyyy-MM-dd");
						} else {
							rs[0] = DateUtil.getSpecDate(curYear, curMonth - 1,
									tStrDay, "yyyy-MM-dd");
							rs[1] = DateUtil.getSpecDate(curYear, curMonth,
									tEndDay, "yyyy-MM-dd");
						}
					} else if (tStrDay < tEndDay) { // 开始日期小于结束日期
						rs[0] = DateUtil.getSpecDate(curYear, curMonth,
								tStrDay, "yyyy-MM-dd");
						rs[1] = DateUtil.getSpecDate(curYear, curMonth,
								tEndDay, "yyyy-MM-dd");
					}

				}
				System.out.println(rs[0] + "," + rs[1]);
			} else {
				GSLogWriter.debug("----查不到结算日期信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("balancedate=" + rs[0] + "," + rs[1]);
		return rs;

	}

	/**
	 * 预定的结算日期
	 * 
	 * @param aOrderDeptId
	 *            订货单位编码
	 * @return
	 */
	public static String[] getBalanceDate() {
		String tRs = "";
		String[] rs = new String[2];

		String tSql = "select * from GS_BALANCE_PARAM ";
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSBalanceParamBean(), tSql, null);
			if (tList.size() > 0) {
				tRs = ((GSBalanceParamBean) tList.get(0))
						.getGs_balance_date_type();
				Calendar c = Calendar.getInstance();
				int month = c.get(Calendar.MONTH);
				int year = c.get(Calendar.YEAR);

				if (GSBaseConstants.NATURE_BALANCE_DATE.equals(tRs)) {
					c.set(year, month - 1, 1);
					int day = c.getActualMaximum(Calendar.DAY_OF_MONTH);
					rs[0] = ""
							+ year
							+ "-"
							+ (month + 1 > 9 ? "" + (month + 1) : "0"
									+ (month + 1)) + "-01";
					rs[1] = ""
							+ year
							+ "-"
							+ (month + 1 > 9 ? "" + (month + 1) : "0"
									+ (month + 1)) + "-" + day;
				} else {
					GSBalanceParamBean b = (GSBalanceParamBean) tList.get(0);
					String startDate = Integer.parseInt(b
							.getGs_balance_start_date()) <= 9 ? "0"
							+ b.getGs_balance_start_date() : b
							.getGs_balance_start_date();
					String endDate = Integer.parseInt(b
							.getGs_balance_end_date()) <= 9 ? "0"
							+ b.getGs_balance_end_date() : b
							.getGs_balance_end_date();

					int tStrDay = Integer.parseInt(startDate);
					int tEndDay = Integer.parseInt(endDate);
					String tCurDay = DateUtil.getCurrentDate("yyyyMMdd");
					int curYear = Integer.parseInt(tCurDay.substring(0, 4));
					int curMonth = Integer.parseInt(tCurDay.substring(4, 6));
					if (tStrDay > tEndDay || tStrDay == tEndDay) { // 开始日期大于等于结束日期
						if (tCurDay.substring(4, 6).equals("01")) { // 如果当前月份为1月,则开始区间的年为上一年份
							rs[0] = DateUtil.getSpecDate(curYear - 1, 12,
									tStrDay, "yyyy-MM-dd");
							rs[1] = DateUtil.getSpecDate(curYear, 1, tEndDay,
									"yyyy-MM-dd");
						} else {
							rs[0] = DateUtil.getSpecDate(curYear, curMonth - 1,
									tStrDay, "yyyy-MM-dd");
							rs[1] = DateUtil.getSpecDate(curYear, curMonth,
									tEndDay, "yyyy-MM-dd");
						}
					} else if (tStrDay < tEndDay) { // 开始日期小于结束日期
						rs[0] = DateUtil.getSpecDate(curYear, curMonth,
								tStrDay, "yyyy-MM-dd");
						rs[1] = DateUtil.getSpecDate(curYear, curMonth,
								tEndDay, "yyyy-MM-dd");
					}

				}
				System.out.println(rs[0] + "," + rs[1]);
			} else {
				GSLogWriter.debug("----查不到结算日期信息");
			}
		} catch (Exception e) {
			GSLogWriter.error(e.toString());
			e.printStackTrace();
		}
		GSLogWriter.debug("balancedate=" + rs[0] + "," + rs[1]);
		return rs;
	}

	public static String[][] getBalanceYears() {
		String[][] tStr = new String[16][2];
		tStr[0][0] = "2005";
		tStr[1][0] = "2006";
		tStr[2][0] = "2007";
		tStr[3][0] = "2008";
		tStr[4][0] = "2009";
		tStr[5][0] = "2010";
		tStr[6][0] = "2011";
		tStr[7][0] = "2012";
		tStr[8][0] = "2013";
		tStr[9][0] = "2014";
		tStr[10][0] = "2015";
		tStr[11][0] = "2016";
		tStr[12][0] = "2017";
		tStr[13][0] = "2018";
		tStr[14][0] = "2019";
		tStr[15][0] = "2020";

		tStr[0][1] = "2005年";
		tStr[1][1] = "2006年";
		tStr[2][1] = "2007年";
		tStr[3][1] = "2008年";
		tStr[4][1] = "2009年";
		tStr[5][1] = "2010年";
		tStr[6][1] = "2011年";
		tStr[7][1] = "2012年";
		tStr[8][1] = "2013年";
		tStr[9][1] = "2014年";
		tStr[10][1] = "2015年";
		tStr[11][1] = "2016年";
		tStr[12][1] = "2017年";
		tStr[13][1] = "2018年";
		tStr[14][1] = "2019年";
		tStr[15][1] = "2020年";
		return tStr;
	}

	public static String[][] getBalanceMonths() {
		String[][] tStr = new String[12][2];
		tStr[0][0] = "01";
		tStr[1][0] = "02";
		tStr[2][0] = "03";
		tStr[3][0] = "04";
		tStr[4][0] = "05";
		tStr[5][0] = "06";
		tStr[6][0] = "07";
		tStr[7][0] = "08";
		tStr[8][0] = "09";
		tStr[9][0] = "10";
		tStr[10][0] = "11";
		tStr[11][0] = "12";
		tStr[0][1] = "1月";
		tStr[1][1] = "2月";
		tStr[2][1] = "3月";
		tStr[3][1] = "4月";
		tStr[4][1] = "5月";
		tStr[5][1] = "6月";
		tStr[6][1] = "7月";
		tStr[7][1] = "8月";
		tStr[8][1] = "9月";
		tStr[9][1] = "10月";
		tStr[10][1] = "11月";
		tStr[11][1] = "12月";
		return tStr;
	}

	public static String[][] getPreFeeType() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "990";
		tRs[0][1] = "预收款";
		tRs[1][0] = "991";
		tRs[1][1] = "预付款";
		return tRs;
	}

	public static String[][] getValidity() {
		String[][] tRs = new String[2][2];
		tRs[0][0] = "0";
		tRs[0][1] = "无效";
		tRs[1][0] = "1";
		tRs[1][1] = "有效";
		return tRs;
	}

	/**
	 * 压库结算单状态
	 * **/
	public static String[][] getStocksState() {
		String[][] sta = new String[4][4];
		sta[0][0] = "0";
		sta[0][1] = "未纳入结算";
		sta[1][0] = "1";
		sta[1][1] = "已纳入结算";
		sta[2][0] = "2";
		sta[2][1] = "已作废";
		sta[3][0] = "3";
		sta[3][1] = "已完成";
		return sta;
	}

	public static String getPreFeeTypeName(String no) {
		String tName = "";
		String[][] tRs = getPreFeeType();
		for (int i = 0; i < tRs.length; i++) {
			if (tRs[i][0].equals(no)) {
				tName = tRs[i][1];
				break;
			}
		}
		return tName;
	}

	public static String toUtf8String(String s) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c >= 0 && c <= 255) {
				sb.append(c);
			} else {
				byte[] b;
				try {
					b = Character.toString(c).getBytes("utf-8");
				} catch (Exception ex) {
					System.out.println(ex);
					b = new byte[0];
				}
				for (int j = 0; j < b.length; j++) {
					int k = b[j];
					if (k < 0)
						k += 256;
					sb.append("%" + Integer.toHexString(k).toUpperCase());
				}
			}
		}
		return sb.toString();
	}

	// 得字典表
	public static String getDictioanryName(String id) {
		String tRs = "";
		if (id == null)
			return tRs;

		GSDictionaryDAO dicDao = new GSDictionaryDAO();
		GSDictionaryBean dicBean = null;
		try {
			dicBean = dicDao.queryById(id);
			if (dicBean != null)
				tRs = dicBean.getName();
		} catch (Exception e) {
		}

		if (tRs == null || tRs.equalsIgnoreCase("")) {
			if (id != null)
				tRs = id.trim();
			else
				tRs = "";
		}

		return tRs;
	}

	/**
	 * 查询最大供应商编号
	 * 
	 * @return
	 */
	public static String getMaxProviderId() {
		// 这里存在BUG
		String tRs = "10000";
		String tSql = "select * from t_PROVIDER where code = (select max(code) from t_PROVIDER)";
		try {
			ArrayList tList = new GSBaseDAO().executeQuery(
					new GSProviderBean(), tSql, null);
			if (tList.size() > 0) {
				tRs = ((GSProviderBean) tList.get(0)).getGs_provider_id();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return tRs;
	}

	/**
	 * 取得是否需采购 1=是 0=否
	 * 
	 * @param aId
	 * @return
	 */
	public static String[][] getAllisbuy() {
		String[][] tStr = new String[2][2];
		tStr[0][0] = "1";
		tStr[0][1] = "是";
		tStr[1][0] = "0";
		tStr[1][1] = "否";
		return tStr;
	}

	/**
	 * 取得结算模式 0=买断 1=压库
	 * 
	 * @param aId
	 * @return
	 */
	public static String[][] getbalancemode() {
		String[][] tStr = new String[2][2];
		tStr[0][0] = GSBaseConstants.BALANCE_MODE1;
		tStr[0][1] = "压库";
		tStr[1][0] = GSBaseConstants.BALANCE_MODE2;
		tStr[1][1] = "买断";
		return tStr;
	}

	/**
	 * 补货申请单状态
	 * **/
	public static String[][] getApplyStatus() {
		String[][] tStr = new String[3][2];
		tStr[0][0] = GSBaseConstants.ORDER_SUPPLY_APPLY;
		tStr[0][1] = "申请";
		tStr[1][0] = GSBaseConstants.ORDER_SUPPLY_AGREE;
		tStr[1][1] = "已完成";
		tStr[2][0] = GSBaseConstants.ORDER_SUPPLY_NOAGREE;
		tStr[2][1] = "已拒绝";
		return tStr;
	}

	/**
	 * 取得所有启用状态
	 * 
	 * @return
	 */
	public static String[][] getAllStatus() {
		String[][] tRs = new String[3][2];
		tRs[0][0] = "0";
		tRs[0][1] = "未启用";
		tRs[1][0] = "1";
		tRs[1][1] = "已启用";
		tRs[2][0] = "2";
		tRs[2][1] = "启用出错";
		return tRs;
	}

	/**
	 * 根据启用状态得到对应名称
	 * 
	 * @param aStatus
	 *            状态编码
	 * @return
	 */
	public static String getStatusName(String aStatus) {
		String tName = "";
		String[][] tRs = getAllStatus();
		for (int i = 0; i < tRs.length; i++) {
			if (tRs[i][0].equals(aStatus)) {
				tName = tRs[i][1];
				break;
			}
		}
		return tName;
	}

	/**
	 * 取得所有审批状态
	 * 
	 * @return
	 */
	public static String[][] getAllAuditingStatus() {
		String[][] tRs = new String[3][2];
		tRs[0][0] = "0";
		tRs[0][1] = "待审批";
		tRs[1][0] = "1";
		tRs[1][1] = "审批通过";
		tRs[2][0] = "2";
		tRs[2][1] = "审批不通过";
		return tRs;
	}

	/**
	 * 根据启用状态得到对应名称
	 * 
	 * @param aStatus
	 *            状态编码
	 * @return
	 */
	public static String getAuditingStatusName(String aStatus) {
		String tName = "";
		String[][] tRs = getAllAuditingStatus();
		for (int i = 0; i < tRs.length; i++) {
			if (tRs[i][0].equals(aStatus)) {
				tName = tRs[i][1];
				break;
			}
		}
		return tName;
	}

	/**
	 * 根据文件夹下的第一张图片
	 * 
	 * @param aStatus
	 *            状态编码
	 * @return
	 */
	public static String getFirstPictureHtmlCode(String code) {
		/**
		 * <a href="D:/change1234567/1.gif" class="jqzoom" title=""> <img
		 * src="D:/change1234567/1.gif" alt="" id="current_img"> </a>
		 */
		String html = "";
		String path=GSSystemConfigurator.getParam("gs.pic.filePath");
		String imagePath = path + code + "/";
		File file = new File(imagePath);
		String[] tempList = file.list();
		boolean flag = false;

		if (tempList != null) {
			for (int i = 0; i < tempList.length; i++) {
				if (tempList[i].toLowerCase().endsWith(".jpg")
						|| tempList[i].toLowerCase().endsWith(".gif")
						|| tempList[i].toLowerCase().endsWith(".bmp")
						|| tempList[i].toLowerCase().endsWith(".png")) {
					if (!flag) {
					/*	String bigPicture = tempList[i].substring(0,
								tempList[i].length() - 4)
								+ "_"
								+ tempList[i].substring(
										tempList[i].length() - 4,
										tempList[i].length());
						html += " <a href='";
						html += imagePath + bigPicture
								+ "' class='jqzoom'  title=''>";
						html += " <img src='";
						html += imagePath + tempList[i]
								+ "' alt='' id='current_img'></a>";*/
				
			
						html += " <img src='";
						html += "/gw/servlet/ProductPictureShowServlet?path="+imagePath+tempList[i]+"&type=3"
								+ "' alt='' id='current_img'>";
						flag = true;
					}
				}
			}
		}
		return html;
	}

	/**
	 * 根据文件夹下的所有图片
	 * 
	 * @param aStatus
	 *            状态编码
	 * @return
	 */
	public static String getPictureHtmlCode(String code) {

		String html = "";
		String path=GSSystemConfigurator.getParam("gs.pic.filePath");
		String imagePath = path + code + "/";
		File file = new File(imagePath);
		String[] tempList = file.list();

		if (tempList != null) {
			for (int i = 0; i < tempList.length; i++) {
				if (tempList[i].toLowerCase().endsWith(".jpg")
						|| tempList[i].toLowerCase().endsWith(".gif")
						|| tempList[i].toLowerCase().endsWith(".bmp")
						|| tempList[i].toLowerCase().endsWith(".png")) {
						/*String bigPicture = tempList[i].substring(0,
								tempList[i].length() - 4)
								+ "_"
								+ tempList[i].substring(
										tempList[i].length() - 4,
										tempList[i].length());
						html += "<li><img src='";
						html += imagePath + tempList[i] + "' alt='";
						html += imagePath + bigPicture + "' /> </li> ";*/
						
				
						html += "<li><img src='";
						html +="/gw/servlet/ProductPictureShowServlet?path="+imagePath+tempList[i]+"&type=3"
						+ "' alt=''/> </li> ";
					}
				}
		}
		return html;
	}
}
